package cn.itrip.auth.service.impl;

import cn.itrip.auth.service.SmsService;
import com.cloopen.rest.sdk.CCPRestSmsSDK;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;

import java.util.HashMap;
@Service("smsService")
public class SmsServiceImpl implements SmsService {

    @SneakyThrows
    @Override
    public void send(String to, String templateId, String[] datas) throws Exception {
        CCPRestSmsSDK sdk=new CCPRestSmsSDK();
        sdk.init("app.cloopen.com","8883");
        sdk.setAccount( "8aaf07087d7fb5f6017d8f70724a02ef","f892540d223d4f988e4c1ed908a29ee9");
        sdk.setAppId("8aaf07087d7fb5f6017d8f70737302f5");
        HashMap result=sdk.sendTemplateSMS(to, templateId, datas);
        if ("000000".equals(result.get("statusCode"))){
            System.out.println("短信发送成功");

        }else {
            //throw new Exception(result.get("statusCode").toString()+":"+result.get("statusMsg").toString());
        }
    }
}
